﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace Nano.Core.Web
{
    public static class QueryString
    {
        /// <summary>
        /// If named item exists return its value as an object, otherwise empty string.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static string GetNamedItem(string name)
        {
            if (QueryString.Exists(name))
                return HttpContext.Current.Request.QueryString[name];

            return string.Empty;
        }

        /// <summary>
        /// Check that a QueryString exists with the given name.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static bool Exists(string name)
        {
            return (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString[name]));
        }
    }
}
